
package instrumentation;

import java.io.Serializable;
import java.util.BitSet;
import java.util.HashSet;
import java.util.Set;



public class Data implements Serializable, Value {

	private static final long serialVersionUID = -4042773236943535616L;

	private final int id;
	private static int idGenerator = 0;

	private final String fieldName;

	private final BitSet mask;
//	private final Set<DataDef> defs;
//	private final Set<DataUse> uses;

	private boolean field;
	private final boolean param;

	public Data(String fieldName, boolean param) {
		id = idGenerator++;

		this.param = param;
		this.fieldName = fieldName;
		field = fieldName != null;



		mask = new BitSet();
//		defs = new HashSet<DataDef>();
//		uses = new HashSet<DataUse>();
	}

	public int getId() {
		return id;
	}

	public String getFieldName() {
		return fieldName;
	}

	void setField(boolean field) {
		this.field = field;
	}

	public boolean isField() {
		return field;
	}

	public boolean isParam() {
		return param;
	}

	public BitSet getMask() {
		return (BitSet) mask.clone();
	}

//	void addDef(DataDef def) {
//		defs.add(def);
//		mask.set(def.getId());
//	}
//
//	public Set<DataDef> getDefs() {
//		return defs;
//	}
//
//	public Set<DataUse> getUses() {
//		return uses;
//	}
//
//	void addUse(DataUse use) {
//		uses.add(use);
//	}

	@Override
	public String toString() {
		if(param) return "p" + id;
		if(field) return "f" + id;
		return "d" + id;
	}
}
